package com.tgy.thread;

import java.util.concurrent.TimeUnit;

/**
 * @Author: tgy
 * @Date: 12/1/20 4:41 PM
 */
public class JoinDemo {

    public static void main(String[] args) {

        Thread t1 = new Thread(() -> {

            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }, "t1");

        t1.start();

        try {
            /**
             * 如果被等待的线程执行完成，在线程执行完成，就会唤醒当前的线程
             */
            t1.join(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("111");

    }
}
